package utils;

public class Utils {

	public static boolean dentroEllisse(int x, int y, int xc, int yc, int wc, int hc) {
		float a, b;
		a = wc >> 1;
		b = hc >> 1;
		float c, f1x, f2x, f1y, f2y, v;
		if (b <= a) {
			c = (float) Math.sqrt(a * a - b * b);
			f1x = xc + a - c;
			f2x = xc + a + c;
			f1y = yc + b;
			f2y = f1y;
			v = 2 * a;
		} else {
			c = (float) Math.sqrt(b * b - a * a);
			f1y = yc + b - c;
			f2y = yc + b + c;
			f1x = xc + a;
			f2x = f1x;
			v = 2 * b;
		}
		float d = (float) (Math.sqrt((x - f1x) * (x - f1x) + (y - f1y)
				* (y - f1y)) + Math.sqrt((x - f2x) * (x - f2x) + (y - f2y)
				* (y - f2y)));
		return d <= v;
	}
}
